/// <reference path="../../../../../../typings/angularjs/angular.d.ts"/>
/// <reference path="../../../../../../typings/jquery/jquery.d.ts"/>
define(['./../initial', './highchartTheme'], function () {
    var app = angular.module('App.home');
    app.factory('chartFactory', ['$http', '$q', 'highchartTheme', '$rootScope', '$timeout', '$compile', '$filter',
        function ($http, $q, highchartTheme, $rootScope, $timeout, $compile, $filter) {

            //制保留2位小数，如：2，会在2后面补上00.即2.00  
            // function toDecimal2(x) {
            //     var f = Math.round(x * 100) / 100;
            //     var s = f.toString();
            //     var rs = s.indexOf('.');
            //     if (rs < 0) {
            //         rs = s.length;
            //         s += '.';
            //     }
            //     while (s.length <= rs + 2) {
            //         s += '0';
            //     }
            //     return s;
            // }

            var fac = {
                destroy: function (domId) {
                    var dom = $(domId);
                    var chart = dom.highcharts();
                    if (chart) {
                        chart.destroy();
                    }
                    highchartTheme.light();
                },
                createStasticPie: function (domId, dataSet, width, height, chartType) {
                    fac.destroy(domId);
                    //计算总数据
                    var total = 0;
                    dataSet.datas.forEach(function (data) {
                        total = total + data.count;
                    });
                    var yList = [];
                    dataSet.datas.forEach(function (item) {
                        yList.push({
                            name: item.text,
                            y: Math.floor(100 * item.count / dataSet.count),
                            count: item.count,
                            selected: item.selected,
                            sliced: item.sliced
                        });
                    });
                    if (dataSet.count - total > 5) {
                        yList.push({
                            name: '',
                            y: Math.floor(100 * (dataSet.count - total) / dataSet.count),
                            color: 'transparent',
                            dataLabels: { enabled: false }
                        });
                    }
                    var chart = $(domId).highcharts({
                        chart: {
                            plotBackgroundColor: null,
                            plotBorderWidth: null,
                            plotShadow: false,
                            borderColor: "#2D7C7C",
                            borderWidth: 0,
                            style: {
                                fontFamily: '"Microsoft Yahei", Verdana', // default font
                                fontSize: '11px',
                                borderTopLeftRadius: "0px",
                                borderTopRightRadius: "0px",
                                borderBottomLeftRadius: "5px",
                                borderBottomRightRadius: "5px",
                                // boxShadow: "0 0 0 1px rgba(39,41,43,.15),0 1px 2px 0 rgba(0,0,0,.05)"
                            },
                            spacing: [10, 40, 40, 20],
                            margin: [10, 10, 30, 30],
                            backgroundColor: "transparent",
                            borderRadius: 0,
                            height: height || 350,
                            width: width
                        },
                        exporting: {
                            enabled: false
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            text: '', //dataSet.title,
                            align: 'left',
                            style: {
                                fontSize: '18px',
                                letterSpacing: '1px',
                                fontWeight: 'bold',
                                color: "#333"
                            }
                        },
                        tooltip: {
                            formatter: function () {
                                if (this.point.color == "transparent") return false;
                                return '<b>' + this.point.name.replace('<', '&lt;').replace('>', '&gt;') + "</b>:  " + this.point.percentage.toFixed(2) + '%';
                            }
                        },
                        legend: {
                            enabled: true,
                            align: 'center',
                            y: 40
                        },
                        plotOptions: {
                            pie: {
                                // allowPointSelect: true,
                                cursor: 'pointer',
                                colors: ['#5BBD72', '#3B7FE4', '#FFD101', '#F16B17', '#EA3489', '#EA383B'],
                                dataLabels: {
                                    useHTML: false,
                                    enabled: true,
                                    color: '#000000',
                                    connectorColor: '#000000',
                                    formatter: function () {
                                        return '<b>' + this.point.name.replace('<', '&lt;').replace('>', '&gt;') + "</b>:  " + this.point.percentage.toFixed(2) + '%';
                                    }
                                },
                                showInLegend: true
                            },
                            series: {
                                events: {
                                    click: function (event) {
                                        //点击绘制柱状图
                                        dataSet.datas = this.chart.series[0].data.map(function (data) {
                                            return {
                                                text: data.name,
                                                count: data.count
                                            };
                                        }).filter(function (item) {
                                            return item.text;
                                        });
                                        fac.createStastisBar(domId, dataSet, this.chart.chartWidth, this.chart.chartHeight, 'project');
                                    }
                                }
                            }
                        },
                        series: [{
                            type: 'pie',
                            name: '',
                            data: yList
                        }]
                    });
                    return chart;
                },
                changeType: function (chart, series, newType) {
                    newType = newType.toLowerCase();
                    for (var i = 0; i < series.length; i++) {
                        series = series[0];
                        try {
                            series.chart.addSeries({
                                type: newType,
                                stack: series.stack,
                                yaxis: series.yaxis,
                                name: series.name,
                                color: series.color,
                                data: series.options.data
                            },
                                false);
                            series.remove();
                        } catch (e) {
                            alert(newType + ': ' + e);
                        }
                    }
                },
                createTotalPointBar: function (domId, dataSet, width, height) {
                    fac.destroy(domId);
                    var showDataLabel = dataSet.series[0].data.length > 10 ? false : true;
                    var chart = $(domId).highcharts({
                        chart: {
                            type: 'column',
                            borderColor: "#2D7C7C",
                            borderWidth: 0,
                            style: {
                                fontFamily: '"Microsoft Yahei", Verdana', // default font
                                fontSize: '11px',
                                borderTopLeftRadius: "0px",
                                borderTopRightRadius: "0px",
                                borderBottomLeftRadius: "5px",
                                borderBottomRightRadius: "5px"
                                // boxShadow: "0 0 0 1px rgba(39,41,43,.15),0 1px 2px 0 rgba(0,0,0,.05)"
                            },
                            spacing: [10, 40, 40, 20],
                            backgroundColor: "transparent",
                            margin: [10, 10, null, 30],
                            borderRadius: 0,
                            height: height || 350,
                            width: width
                        },
                        exporting: {
                            enabled: false
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            text: dataSet.title,
                            align: 'left',
                            x: 20,
                            style: {
                                fontSize: '16px',
                                letterSpacing: '1px',
                                fontWeight: 'bold',
                                color: "#444"
                            }
                        },
                        xAxis: {
                            categories: dataSet.categories,
                            gridLineColor: "transparent",
                            tickmarkPlacement: 'on',
                            lineColor: '#444',
                            tickLength: 4,
                            labels: {
                                rotation: 90,
                                y: 20
                            }
                        },
                        yAxis: {
                            lineWidth: 1,
                            tickLength: 4,
                            gridLineColor: "#f6f6f6",
                            lineColor: '#444',
                            title: {
                                text: '个',
                                rotation: 0,
                                y: -10
                            },
                            min: 0,
                            labels: {
                                x: -3,
                                style: {
                                    color: '#444',
                                    font: '12px'
                                }
                            }
                        },
                        legend: {
                            enabled: true,
                            align: 'center'
                        },
                        tooltip: {
                            headerFormat: '{series.name}:',
                            pointFormat: '{point.y}个',
                            useHTML: false
                        },
                        plotOptions: {
                            column: {
                                dataLabels: {
                                    enabled: showDataLabel,
                                    format: "{y}"
                                }
                            }
                        },
                        series: dataSet.series
                    });
                    return chart;
                },
                createStastisBar: function (domId, dataSet, width, height, chartType) {

                    fac.destroy(domId);
                    var yList = dataSet.datas.map(function (item) {
                        return item.count;
                    });
                    var max = chartType === 'project' ? Math.floor(Math.max.apply(null, yList) * 1.1) : null;
                    var chart = $(domId).highcharts({
                        chart: {
                            type: 'column',
                            borderColor: "#2D7C7C",
                            borderWidth: 0,
                            style: {
                                fontFamily: '"Microsoft Yahei", Verdana', // default font
                                fontSize: '11px',
                                borderTopLeftRadius: "0px",
                                borderTopRightRadius: "0px",
                                borderBottomLeftRadius: "5px",
                                borderBottomRightRadius: "5px",
                                // boxShadow: "0 0 0 1px rgba(39,41,43,.15),0 1px 2px 0 rgba(0,0,0,.05)"
                            },
                            spacing: [10, 40, 40, 20],
                            margin: [30, 10, 30, 30],
                            backgroundColor: "transparent",
                            borderRadius: 0,
                            height: height || 350,
                            width: width
                        },
                        exporting: {
                            enabled: false
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            text: dataSet.title,
                            align: 'center',
                            x: 20,
                            y: 10,
                            style: {
                                fontSize: '16px',
                                letterSpacing: '1px',
                                fontWeight: 'bold',
                                color: "#444"
                            }
                        },
                        xAxis: {
                            categories: (function () {
                                return dataSet.datas.map(function (item, index) {
                                    return item.text;
                                });
                            })(),
                            gridLineColor: "transparent",
                            tickmarkPlacement: 'on',
                            lineColor: '#444',
                            tickLength: 4
                        },
                        yAxis: {
                            lineWidth: 1,
                            tickLength: 4,
                            gridLineColor: "#f6f6f6",
                            lineColor: '#444',
                            title: {
                                text: '个',
                                rotation: 0,
                                offset: -10
                            },
                            min: 0,
                            max: max,
                            labels: {
                                x: -3,
                                style: {
                                    color: '#444',
                                    font: '12px'
                                }
                            }
                        },
                        legend: {
                            enabled: false,
                        },
                        tooltip: {
                            headerFormat: '{point.x}:',
                            pointFormat: '{point.y}个',
                            useHTML: false
                        },
                        plotOptions: {
                            series: {
                                cursor: 'pointer',
                                events: {
                                    click: function (event) {
                                        //点击绘制饼状图
                                        if (!this.chart.notFinish) {
                                            dataSet.datas = this.chart.series[0].data.map(function (data, index) {
                                                return {
                                                    text: data.category,
                                                    count: data.y,
                                                    selected: event.point.x === index ? true : false,
                                                    sliced: event.point.x === index ? true : false
                                                };
                                            });
                                            fac.createStasticPie(domId, dataSet, this.chart.chartWidth, this.chart.chartHeight);
                                        }
                                    }
                                }
                            },
                            column: {
                                dataLabels: {
                                    enabled: true,
                                    format: "{y}",
                                    crop: false,
                                    overflow: 'none',
                                    inside: false
                                },
                                colorByPoint: true,
                                colors: ['#5BBD72', '#3B7FE4', '#FFD101', '#F16B17', '#EA3489', '#EA383B'],
                            }
                        },
                        series: [{
                            name: dataSet.title,
                            data: yList
                        }]
                    });
                    return chart;
                },
                createPointsChartByLocationSummary: function (domId, dataSet, width) {
                    var defer = $q.defer();
                    var dom = $(domId);
                    var chart = dom.highcharts();
                    if (chart) {
                        chart.destroy();
                    }
                    highchartTheme.light();
                    var xAxisInterval = 1,
                        base = 25;
                    if (dataSet.lastValues.length > base * 2) {
                        xAxisInterval = Math.floor(dataSet.lastValues.length / base) + 3;
                    } else if (dataSet.lastValues.length > base) {
                        xAxisInterval = Math.floor(dataSet.lastValues.length / base) + 2;
                    }

                    $(domId).highcharts({
                        chart: {
                            type: 'line',
                            borderColor: "#2D7C7C",
                            borderWidth: 0,
                            style: {
                                fontFamily: '"Microsoft Yahei", Verdana', // default font
                                fontSize: '11px',
                                borderTopLeftRadius: "0px",
                                borderTopRightRadius: "0px",
                                borderBottomLeftRadius: "5px",
                                borderBottomRightRadius: "5px",
                                // boxShadow: "0 0 0 1px rgba(39,41,43,.15),0 1px 2px 0 rgba(0,0,0,.05)"
                            },
                            spacing: [10, 40, 40, 20],
                            margin: [10, 30, 30, 30],
                            backgroundColor: "transparent",
                            borderRadius: 0,
                            height: 300,
                            width: width ? width : null
                        },
                        exporting: {
                            enabled: false
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            align: 'left',
                            text: "", //dataSet.title,
                            fontFamily: "'Microsoft Yahei', Verdana",
                            x: 10
                        },
                        xAxis: {
                            categories: (function () {
                                return dataSet.lastValues.map(function (item, index) {
                                    return item.name;
                                });
                            })(),
                            gridLineColor: "transparent",
                            labels: {
                                style: {
                                    color: '#555',
                                    font: '12px',
                                    fontWeight: "bold"
                                },
                                step: xAxisInterval,
                                staggerLines: 1
                            },
                            tickmarkPlacement: 'on',
                            lineColor: '#444',
                            tickLength: 4
                        },
                        yAxis: {
                            lineWidth: 1,
                            tickLength: 4,
                            gridLineColor: "#f0f0f0",
                            lineColor: '#444',
                            title: {
                                text: ''
                            },
                            minTickInterval: 1,
                            max: (dataSet.max - dataSet.min > 5) ? dataSet.max + 2 : dataSet.max + 3,
                            min: (dataSet.max - dataSet.min > 5) ? dataSet.min - 2 : dataSet.min - 3,
                            labels: {
                                x: -3,
                                style: {
                                    color: '#444',
                                    font: '12px'
                                }
                            }
                        },
                        legend: {
                            align: 'right',
                            verticalAlign: 'top',
                            floating: true,
                            borderWidth: 0,
                            y: -6
                        },
                        tooltip: {
                            headerFormat: '<b>{point.x}</b>:',
                            pointFormat: '{point.y}mm'
                        },
                        plotOptions: {
                            line: {
                                lineWidth: 1,
                                animation: false,
                                marker: {
                                    radius: 2
                                },
                                dataLabels: {
                                    enabled: true,
                                    color: "#333",
                                    useHTML: true,
                                    zIndex: 2,
                                    formatter: function () {
                                        if (this.point.remark) {
                                            var htmlStr = "";
                                            htmlStr = '<div style="color:#333;z-index:40;width:1em;letter-spacing:1em;white-space: normal;font-size:12px;"><br><br>' + this.point.remark + '<br><br></div>';
                                            return htmlStr;
                                        } else return '';
                                    }
                                }
                            },
                            series: {
                                cursor: 'pointer',
                                marker: {
                                    lineWidth: 0
                                },
                                point: {
                                    events: {
                                        click: function (event) {
                                            event.stopPropagation();
                                            var ptName = this.name;
                                            $rootScope.$broadcast('chartPointClick', ptName);
                                        }
                                    }
                                }
                            }
                        },
                        series: [{
                            name: dataSet.lastTime,
                            data: (function () {
                                return dataSet.lastValues.map(function (item, index) {
                                    return {
                                        name: item.name,
                                        y: item.value,
                                        remark: item.remark,
                                        marker: (function () {
                                            return {
                                                enabled: true,
                                                radius: 2
                                            };
                                            // if (item.name === dataSet.maxPointAllTheTime.name) {
                                            //     return {
                                            //         lineWidth: 1,
                                            //         enabled: true,
                                            //         lineColor: "#111",
                                            //         radius: 5
                                            //     };
                                            // } else if (item.name === dataSet.maxPointThisTime.name) {
                                            //     return {
                                            //         enabled: true,
                                            //         radius: 5
                                            //     };
                                            // } else {

                                            // }
                                        })()
                                    };
                                });
                            })()
                        }, {
                                name: dataSet.curTime,
                                data: (function () {
                                    return dataSet.curValues.map(function (item, index) {
                                        return {
                                            name: item.name,
                                            y: item.value,
                                            marker: (function () {
                                                return {
                                                    enabled: true,
                                                    radius: 2
                                                };
                                                // if (item.name === dataSet.maxPointAllTheTime.name) {
                                                //     return {
                                                //         lineWidth: 1,
                                                //         lineColor: "#111",
                                                //         enabled: true,
                                                //         radius: 5
                                                //     };
                                                // } else if (item.name === dataSet.maxPointThisTime.name) {
                                                //     return {
                                                //         enabled: true,
                                                //         radius: 5
                                                //     };
                                                // } else {

                                                // }
                                            })()
                                        };
                                    });
                                })()
                            }]
                    });
                    defer.resolve(null);
                    return defer.promise;
                },
                createSinglePointChangesChart: function (domId, dataSet, prj) {
                    var yMax, yMin, yValues;
                    //统计Y值
                    yValues = dataSet.map(function (item) {
                        return item.value;
                    });
                    yMax = Math.max.apply(null, yValues);
                    yMin = Math.min.apply(null, yValues);
                    function getYInterval(max, min) {
                        var yInterval = Math.floor(((max - min) / 20));
                        yInterval = yInterval === 0 ? 5 : yInterval * 5;
                        return yInterval;
                    }
                    var yInterval = getYInterval(yMax, yMin);

                    var timeList = dataSet.map(function (item) {
                        return new Date(item.time).getTime();
                    });
                    var min = timeList[0];
                    var max = timeList[timeList.length - 1];
                    var itmeInterval = (max - min) / 5;
                    fac.destroy(domId);
                    highchartTheme.transparent();
                    //复制工况到dataSet中
                    if (prj) {
                        if (prj.mainStatusTimeList && prj.mainStatusTimeList.length > 0) {
                            prj.mainStatusTimeList.forEach(function (item) {
                                //标记为没使用
                                item.used = false;
                            });


                            dataSet.forEach(function (changeItem) {
                                var tempDiff = prj.mainStatusTimeList.map(function (item) {
                                    return Math.abs(Date.parse(changeItem.time) - item.date);
                                });

                                var min = Math.min.apply(null, tempDiff);
                                if (min < 345600000) {
                                    var index = tempDiff.indexOf(min);
                                    if (!prj.mainStatusTimeList[index].used) {
                                        changeItem.status = prj.mainStatusTimeList[index].status;
                                        prj.mainStatusTimeList[index].used = true;
                                    } else {
                                        changeItem.status = "";
                                    }
                                } else {
                                    changeItem.status = "";
                                }
                            });
                        }
                    }
                    $(domId).highcharts({
                        chart: {
                            type: 'line',
                            spacingLeft: 30,
                            spacingRight: 30,
                            margin: [70, 10, 40, 40],
                        },
                        exporting: {
                            enabled: false
                        },
                        credits: {
                            enabled: false
                        },
                        title: {
                            align: 'center',
                            text: dataSet[0].name,
                            y: 32
                        },
                        xAxis: {
                            type: 'datetime',
                            tickmarkPlacement: 'on',
                            tickLength: 4,
                            tickInterval: itmeInterval, // one day
                            labels: {
                                formatter: function () {
                                    var dt = new Date(this.value);
                                    return $filter('date')(dt, 'yyyy-MM-dd');
                                },
                                style: {
                                    color: '#fff',
                                    fontSize: "12"
                                },
                                y: 28 //-13
                            }
                        },
                        yAxis: {
                            lineWidth: 0,
                            tickLength: 0,
                            gridLineWidth: 1,
                            gridLineColor: "#3f3f3f",
                            tickColor: '#999',
                            lineColor: '#999',
                            title: {
                                text: ''
                            },
                            tickInterval: yInterval,
                        },
                        legend: {
                            enabled: false
                        },
                        tooltip: {
                            useHTML: "true",
                            formatter: function () {
                                return this.point.time + "<br>" + this.point.y + "mm";
                            }
                        },
                        plotOptions: {
                            line: {
                                animation: false,
                                pointPlacement: 'on',
                                dataLabels: {
                                    enabled: true,
                                    color: "#ddd",
                                    useHTML: true,
                                    zIndex: 2,
                                    formatter: function () {
                                        var s = this.point.status;
                                        if (s) {
                                            var htmlStr = '<div style="font-size:12px;z-index:40;width:1.5em;">' + Array.prototype.join.call(s, '<br>') + '</div>';
                                            return htmlStr;
                                        } else return '';
                                    }
                                },
                                marker: {
                                    lineWidth: 0,
                                    lineColor: "transparent"
                                }
                            },
                            series: {
                                cursor: 'pointer',
                                marker: {
                                    lineWidth: 1
                                }
                            }
                        },
                        series: [{
                            name: '1',
                            data: (function () {
                                return dataSet.map(function (item) {
                                    return {
                                        x: new Date(item.time),
                                        y: item.value,
                                        status: item.status,
                                        time: item.time
                                    };
                                });
                            })()
                        }]
                    });
                },
                exportChart: function (domId, exportType) {
                    var chart = $('#' + domId).highcharts();
                    if (exportType === 'pic') {
                        chart.exportChart({
                            type: "image/png",
                            url: "/exportChart",
                            sourceWidth: chart.chartWidth,
                            sourceHeight: chart.chartHeight,
                            downloadName: $rootScope.curPrj.name + "-" + chart.title.textStr + '.png'
                        });
                    } else if (exportType === 'pdf') {
                        chart.exportChart({
                            type: "application/pdf",
                            url: "/exportChart",
                            downloadName: $rootScope.curPrj.name + "-" + chart.title.textStr + '.pdf'
                        });
                    } else if (exportType === "whiteSinglePic") {
                        //重写单点变化曲线的白色的样式
                        var chartStyle = {
                            colors: ['#E94E51'],
                            chart: {
                                backgroundColor: "#fff"
                            },
                            title: {
                                style: {
                                    color: '#272727'
                                }
                            },
                            xAxis: [$.extend(chart.xAxis[0].options, {
                                labels: {
                                    formatter: function () {
                                        var dt = new Date(this.value);
                                        return $filter('date')(dt, 'yyyy-MM-dd');
                                    },
                                    style: {
                                        color: '#272727'
                                    }
                                }
                            })],
                            yAxis: [$.extend(chart.yAxis[0].options, {
                                labels: {
                                    style: {
                                        color: '#272727'
                                    }
                                },
                                gridLineColor: "#D9D9D9"
                            })],
                            plotOptions: {
                                line: {
                                    animation: false,
                                    pointPlacement: 'on',
                                    dataLabels: {
                                        enabled: true,
                                        color: "#333",
                                        useHTML: true,
                                        zIndex: 40,
                                        formatter: function () {
                                            return this.point.status;
                                        }
                                    },
                                    marker: {
                                        lineWidth: 0,
                                        lineColor: "transparent"
                                    }
                                },
                            }
                        };
                        chart.series[0].options.dataLabels.color = "#111";
                        chart.exportChart({
                            type: "image/png",
                            url: "/exportChart",
                            sourceWidth: chart.chartWidth,
                            sourceHeight: chart.chartHeight,
                            downloadName: $rootScope.curPrj.name + "-" + chart.title.textStr + '.png'
                        }, chartStyle);

                    } else if (exportType === 'whitePic') {
                        //重写白色的样式
                        var chartLigthStyle = {
                            colors: ['#E94E51', '#0FBDFF', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
                            chart: {
                                backgroundColor: "#fff",
                                borderColor: 'transparent',
                                borderWidth: 1,
                                borderRadius: 0,
                                plotBackgroundColor: 'transparent',
                                plotBorderColor: 'transparent',
                                spacing: [10, 10, 10, 10],
                                margin: [10, 10, 28, 35],
                                style: {
                                    fontFamily: '"Microsoft Yahei", Verdana', // default font
                                    fontSize: '11px',
                                    color: '#4E5043'
                                }
                            },
                            title: {
                                style: {
                                    color: '#272727',
                                    font: '16px'
                                }
                            },
                            xAxis: [{
                                type: "category",
                                categories: chart.xAxis[0].categories,
                                gridLineColor: 'transparent',
                                gridLineWidth: 0,
                                lineColor: '#515346',
                                tickColor: '#515346',
                                tickmarkPlacement: 'on',
                                tickLength: 4,
                                labels: {
                                    step: chart.xAxis[0].userOptions.labels.step,
                                    staggerLines: 1,
                                    style: {
                                        color: '#424338',
                                        font: '12px'
                                    }
                                }
                            }],
                            yAxis: [{
                                gridLineColor: '#f1f1f1',
                                gridLineWidth: 1,
                                lineColor: '#515346',
                                lineWidth: 1,
                                minTickInterval: 1,
                                tickLength: 4,
                                tickInterval: chart.yAxis[0].tickInterval,
                                max: chart.yAxis[0].max,
                                min: chart.yAxis[0].min,
                                tickColor: '#515346',
                                labels: {
                                    style: {
                                        color: '#424338',
                                        fontSize: '12px'
                                    }
                                }
                            }],
                            legend: {
                                itemStyle: {
                                    color: '#282923',
                                    "fontWeight": "bold"
                                },
                            },
                            plotOptions: {
                                line: {
                                    lineWidth: 1,
                                    marker: {
                                        radius: 3
                                    }
                                }
                            }
                        };
                        chart.exportChart({
                            type: "image/png",
                            url: "/exportChart",
                            downloadName: $rootScope.curPrj.name + "-" + chart.title.textStr + '.png'
                        }, chartLigthStyle);
                    }
                }
            };
            return fac;
        }
    ]);
});
